<?php
/**
 * Created by PhpStorm.
 * User: zyw
 * Date: 2018-03-17
 * Time: 17:09
 */
require_once "sms/SmsMultiSender.php";//短信群发
require_once "sms/SmsSingleSender.php";//短信单发
require_once "sms/SmsVoiceVerifyCodeSender.php";//语音验证码发送
require_once "sms/SmsVoicePromptSender.php";//语音通知发送

use Sms\SmsSingleSender;
use Sms\SmsMultiSender;
use Sms\SmsVoicePromptSender;
use Sms\SmsVoiceVerifyCodeSender;


class SyncSms{

    private static $instance;

    static function getInstance(){
        if(!isset(self::$instance)){
            self::$instance = new SyncSms();
        }
        return self::$instance;
    }

    /**
     * 发送短信验证码
     * @param $mobile
     * @param $code
     * @return array
     */
    public function sendCode($mobile, $code){
        $appid = "140002850766";
        $appkey = "8b9a3f55249773ab0dd36d6ce85e5098";
        $singleSender = new SmsSingleSender($appid, $appkey);

        $params = array($code, "5");
        $templId = 95319;
        $sign = '暖光科技';

        $result = $singleSender->sendWithParam("86", $mobile, $templId, $params, $sign,"");
        $res = json_decode($result, true);
        if($res["result"] == 0){
            return array("status"=>0, "msg" => "发送成功");
        }else{
            return array("status"=>-1, "msg" => $res["errmsg"]);
        }
    }

}